package com.czp.controller;

import com.czp.pojo.Article;
import com.czp.service.ArticleService;
import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.text.DateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Controller
@RequestMapping("article")
public class ArticleController {

    @Autowired
    ArticleService articleService;

    @GetMapping
    public String index(Model model,
                        @RequestParam(value = "pageNum",defaultValue = "0") int pageNum,
                        @RequestParam(value = "pageSize",defaultValue = "2") int pageSize){

        Page<Article> page = articleService.findAllArticle(pageNum,pageSize);
        model.addAttribute("page",page);
        return "client/index";

    }
}
